<script>
    $(document).ready(function() {
        $('#datepicker1').datepicker();
        $('#datepicker2').datepicker();
    });

    function post() {
        
        $.post('<?php echo base_url(); ?>reservation/editSave/',{
            guest_id: $("#guest_id").val(),
            status: $("#status").val(),
            checkin: $('#date1').val(),
            checkout: $('#date2').val(),
            adult: $('#adult').val(),
            child: $('#child').val(),
            infant: $('#infant').val(),
            resv_id:$('#resv_id').val()
        },function(){
        window.location.replace("../../reservation");
        });
    }
</script>

<form action="" method="post">
    <table class="table table-hover table-condensed">
        <input type="hidden" id="resv_id" value="<?php echo $data['resv_id']; ?>"/>
        <tr>
            <td>Guest</td>
            <td><input type="text" id="guest_name" name="guest_name" class="input" disabled value="<?php echo $data['guest_name'];?>"></td>
        </tr>
        <tr>
            <td>Status</td>
            <td>
                <select name="status" id="status">
                    <option value="2" <?php if($data['resv_status']==2)echo ':selected';;?>>Check In</option>
                    <option value="1" <?php if($data['resv_status']==1)echo ':selected';?>>Check Out</option>
                    <option value="0" <?php if($data['resv_status']==1) echo ':selected';?>>Cancel</option>
                </select> 
            </td>
        </tr>
        <tr>
            <td>Tanggal Check In</td>
            <td>
                <div class="input-append date" data-date="" data-date-format="yyyy-mm-dd">
                    <input id="date1" type="text" name="checkin" disabled value="<?php echo $data['resv_checkin'];?>">
                    <span class="add-on">
                        <i class="icon-th">
                        </i>
                    </span>
                </div>
            </td>
        </tr>
        <tr>
            <td>Tanggal Check Out</td>
            <td>
                <div class="input-append date" id="datepicker2" data-date="" data-date-format="yyyy-mm-dd">
                    <input id="date2" type="text" name="checkout" disabled value="<?php echo $data['resv_checkout'];?>">
                    <span class="add-on">
                        <i class="icon-th">
                        </i>
                    </span>
                </div>
            </td>
        </tr>
        <tr>
            <td>Jumlah Dewasa</td>
            <td><input id="adult" type="number" name="jml_dewasa" value="<?php echo $data['resv_adult_number'];?>"></td>
        </tr>
        <tr>
            <td>Jumlah Anak-anak</td>
            <td><input id="child" type="number" name="jml_anak" value="<?php echo $data['resv_child_number'];?>"></td>
        </tr>
        <tr>
            <td>Jumlah Bayi</td>
            <td><input id="infant" type="number" name="jml_bayi" value="<?php echo $data['resv_infant_number'];?>"></td>
        </tr>
    </table>
    <input type="hidden" name="guest_id" id="guest_id" value="">
    <a class="btn btn-primary" onclick="post();" >Simpan</a><a class="btn btn-warning" href="<?php echo base_url(); ?>reservation/editRoom/<?php echo $data['resv_id']?>">View Room</a>
</form>
